<!-- 体验版-->
<template>
  <div>
    <div id="member" v-show="boxShow">
      <div class="memberBox">
        <!-- <span class="close" @click="close">
          <i class="icon sp-x_nor"></i>
        </span> -->
        <login ref="myLogin" :show.sync="type" @toggleType="toggleType"></login>
        <register
          ref="myRegister"
          :show.sync="type"
          @toggleType="toggleType"
        ></register>
        <forget
          ref="myForget"
          :show.sync="type"
          @toggleType="toggleType"
        ></forget>
      </div>
    </div>
  </div>
</template>

<script>
const login = () => import("./login");
const register = () => import("./register");
const forget = () => import("./forget");
import { CLIENT } from "@/common/const";
export default {
  data() {
    return {
      boxShow: false,
      type: 0,
      path: CLIENT,
      urlParams: this.$fn.getUrlParams(),
    };
  },
  components: {
    login: login,
    register: register,
    forget: forget,
  },
  mounted() {
    this.boxShow = true;
    this.type = this.urlParams.type;
  },
  methods: {
    close() {
      this.boxShow = false;
      this.$refs.myLogin.initialize();
      this.$refs.myRegister.initialize();
      this.$refs.myForget.initialize();
    },
    toggleType(num) {
      this.type = num;
    },
    getParamsFromURL(url = window.location.href) {
      if ("undefined" == url) {
        return {};
      }
      let paraString = url
        .substring(url.indexOf("?") + 1, url.length)
        .split("&");
      let paraObj = {};
      for (let i = 0; i < paraString.length; i++) {
        let j = paraString[i];
        paraObj[j.substring(0, j.indexOf("="))] = j.substring(
          j.indexOf("=") + 1,
          j.length
        );
      }
      return paraObj;
    },
  },
};
</script>
<style lang="scss" scoped>
.memberBox {
  width: 358px;
  height: 493px;
  background: #fff;
  position: absolute;
  overflow: hidden;
  top: 50%;
  margin-top: -246.5px;
  left: 50%;
  margin-left: -179px;
  .close {
    position: absolute;
    display: inline-block;
    width: 34px;
    height: 34px;
    line-height: 34px;
    right: 0;
    top: 0;
    text-align: center;
    cursor: pointer;
    &:hover {
      background: #ea2827;
      .icon {
        background-position: -144px -94px;
      }
    }
    &:active {
      background: #c11c1b;
    }
    &:after {
      content: "";
      display: inline-block;
      width: 0;
      height: 100%;
      vertical-align: middle;
    }
    .icon {
      display: inline-block;
      vertical-align: middle;
    }
  }
}
</style>
